import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

// 1. 路由定义.
const routes = [
    { path: '', redirect: '/dashboard' },
    { path: '/dashboard', component: () => import('../views/dashboard/Dashboard.vue') },
    { path: '/services', component: () => import('../views/services/Services.vue') },
    { path: '/instances/:sid', component: () => import('../views/services/Instances.vue') },
    {
        path: '/instance/:id',
        component: () => import('../views/services/instance/Instance.vue'),
        children: [
            {
                path: '',
                redirect: 'info',
            },
            {
                path: 'info',
                component: () => import('../views/services/instance/Detail.vue'),
            },
            {
                path: 'level',
                component: () => import('../views/services/instance/Level.vue'),
            },
            {
                path: 'environment',
                component: () => import('../views/services/instance/Environment.vue'),
            },
            {
                path: 'log',
                component: () => import('../views/services/instance/Log.vue'),
            },
            {
                path: 'gc',
                component: () => import('../views/services/instance/GcLog.vue'),
            },
            {
                path: 'jvm',
                component: () => import('../views/services/instance/Jvm.vue'),
            },
            {
                path: 'thread',
                component: () => import('../views/services/instance/Thread.vue'),
            },
        ],
    },
    { path: '/audit', component: () => import('../views/audit/Audit.vue') },
];

// 2. 路由配置.
const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes,
});

export default router;
